// pages/medicine/medicine.js
const nav_img_black = 'https://witty6.oss-cn-beijing.aliyuncs.com/demo/64241692603437_.pic.jpg'
Page({
  data: {
    nav_show:true,
    nav_title:'秉华健康-健康数据管家',
    fontColor:'#333333',
    nav_img:nav_img_black,
    symptom_name:'',
    list:[
      {name:'脾胃消化',content:'脾胃消化'},
      {name:'肝胆系统',content:'肝胆系统'},
      {name:'心血管系统',content:'心血管系统'},
      {name:'肺呼吸系统2211',content:'肺呼吸系统2211'},
      {name:'心血管系统',content:'心血管系统'},
      {name:'心血管系统111',content:'心血管系统111'},
    ],
    list_detail_name:'',
    list_detail_content:'',
    show_right:false,
    list_medicine:[
      {name:'口/饮食',child:[{id:"0",name:"111",wm:"0"},{id:"1",name:"2222",wm:"1"},{id:"2",name:"3333",wm:"0"}]},
      {name:'打嗝/反酸/呕吐',child:[{id:"0",name:"肝胆系统中医",wm:"0"},{id:"1",name:"肝胆系统西医",wm:"1"}]},
      {name:'两便 拷贝',child:[{id:"0",name:"心血管系统中医",wm:"0"},{id:"1",name:"心血管系统西医",wm:"1"}]},
      {name:'肺呼吸系统2211',child:[{id:"0",name:"肺呼吸系统中医",wm:"0"},{id:"1",name:"肺呼吸系统西医",wm:"1"}]},
      {name:'心血管系统',child:[{id:"0",name:"心血管系统中医",wm:"0"},{id:"1",name:"心血管系统西医",wm:"1"}]},
      {name:'心血管系统111',child:[{id:"0",name:"心血管系统中医",wm:"0"},{id:"1",name:"心血管系统西医",wm:"1"}]},
      {name:'肺呼吸系统',child:[{id:"0",name:"肺呼吸系统中医",wm:"0"},{id:"1",name:"肺呼吸系统西医",wm:"1"}]},
      {name:'肺呼吸系统2211',child:[{id:"0",name:"肺呼吸系统中医",wm:"0"},{id:"1",name:"肺呼吸系统西医",wm:"1"}]},
      {name:'心血管系统',child:[{id:"0",name:"心血管系统中医",wm:"0"},{id:"1",name:"心血管系统西医",wm:"1"}]},
      {name:'心血管系统111',child:[{id:"0",name:"心血管系统中医",wm:"0"},{id:"1",name:"心血管系统西医",wm:"1"}]},
      {name:'肺呼吸系统',child:[{id:"0",name:"肺呼吸系统中医",wm:"0"},{id:"1",name:"肺呼吸系统西医",wm:"1"}]},
    ],
    parentindex111:'-1',
    childindex111:'-1',
    list_medicine_symptom:[
      {name:'证型',content:'脾胃消化'},
      {name:'1.宿食积滞',content:'宿食积滞',plan:'25%'},
      {name:'2.瘀血停滞',content:'瘀血停滞',plan:'25%'},
      {name:'3.湿热中阻',content:'湿热中阻',plan:'25%'},
      {name:'4.胃阴不足',content:'胃阴不足',plan:'25%'},
      {name:'5.脾胃虚寒',content:'脾胃虚寒',plan:'25%'},
    ],
  },
  onLoad(options) {
    this.setData({
      symptom_name:options.name,
      list_detail_name:this.data.list[0].name,
      list_detail_content:this.data.list[0].content
    })
  },
  sidebar(e){
    this.setData({
      list_detail_name:this.data.list[e.currentTarget.dataset.index].name,
      list_detail_content:this.data.list[e.currentTarget.dataset.index].content
    })
  },
  show_right_box(){
    this.setData({
      show_right:true,

    })
  },
  onClose() {
    this.setData({ 
      show_right: false,
      parentindex111:"-1",
      childindex111:"-1",
     });
  },
  list_medicine_symptom(){
    this.setData({ 
      show_right: false,
      list:this.data.list_medicine_symptom
    });
  },
  active(e){
    let parentindex111 = e.currentTarget.dataset.parentindex
    let childindex111 = e.currentTarget.dataset.childindex
    for (let i = 0; i < this.data.list_medicine[parentindex111].child.length; i++) {
      if (this.data.list_medicine[parentindex111].child[i].id == childindex111) {
        if (this.data.list_medicine[parentindex111].child[i].checked == true) {
          this.data.list_medicine[parentindex111].child[i].checked = false;
        } else {
          this.data.list_medicine[parentindex111].child[i].checked = true;
        }
      }
    }
    let choseChange = this.data.list_medicine[0].child
    this.setData({
      list_medicine: this.data.list_medicine
    })
  }
})